﻿using System;
using System.Linq;
using System.Collections.Generic; 
using System.Data;
using Matrix.Common.Utility;
using Matrix.MaKaYunShang.Model;
using Matrix.MaKaYunShang.DAL;

namespace Matrix.MaKaYunShang.BLL
{
	public partial class CardRuleDetailBLL : BaseBLL<CardRuleDetailBLL>
	{
		#region 默认方法
		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int  Add(CardRuleDetail model)
		{
			return CardRuleDetailDAL.Instance.Add(model);		
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(CardRuleDetail model)
		{
			return CardRuleDetailDAL.Instance.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int Id)
		{			
			return CardRuleDetailDAL.Instance.Delete(Id);
		}
				/// <summary>
		/// 批量删除一批数据
		/// </summary>
		public bool DeleteList(string Idlist )
		{
			return CardRuleDetailDAL.Instance.DeleteList(Idlist );
		}
		
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public CardRuleDetail GetModel(int Id)
		{
			var ds = CardRuleDetailDAL.Instance.GetModel(Id);
            return ds == null ? null : ServicesHelper.DataSetToIList<CardRuleDetail>(ds).ToList()[0];
		}
		
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<CardRuleDetail> GetModelList(string strWhere = null)
		{
			var ds = CardRuleDetailDAL.Instance.GetList(strWhere);
			return ServicesHelper.DataSetToIList<CardRuleDetail>(ds).ToList();
		}
		#endregion

        #region 扩展方法

        public CardRuleDetail GetModelByRuleBaseId(int ruleBaseId, int cloudCardId)
        {
            DataSet ds = CardRuleDetailDAL.Instance.GetModelByRuleBaseId(ruleBaseId, cloudCardId);
            return ServicesHelper.DataSetToIList<CardRuleDetail>(ds).ToList().FirstOrDefault();
        }
        public List<CardRuleDetail> GetModelByRuleBaseId(int id)
        {
            DataSet ds = CardRuleDetailDAL.Instance.GetModelByRuleBaseId(id);
            return ds == null ? null : ServicesHelper.DataSetToIList<CardRuleDetail>(ds).ToList();
        }

        public List<CardRuleDetail> GetModelListByWhere( string longitude, string latitude, float radius,string strWhere = null)
        {
            DataSet ds = CardRuleDetailDAL.Instance.GetModelListByWhere(strWhere, longitude, latitude, radius);
            return ServicesHelper.DataSetToIList<CardRuleDetail>(ds).ToList();
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        /// <remarks>2016-07-01 万乐园 创建</remarks>
        public bool DeleteByRuleBaseId(int ruleBaseId)
        {
            return CardRuleDetailDAL.Instance.DeleteByRuleBaseId(ruleBaseId);
        }
        #endregion
	}
}